<?php if (!defined('SERVER_ROOT')) exit('No direct script access allowed');

class bacngach_Controller extends Controller {

    function __construct(){
        parent::__construct('quanlyluong', 'bacngach');
        $this->check_login();
        $this->view->template->menu_html =$this->CREATE_MENU();
        $this->view->template->nhacviec_html =$this->CREATE_NHAC_VIEC(); 
        $this->CHECK_QUYEN('quanlyluong', 'bacngach');
    }

    function main(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->dsp_all_bacngach();
    }
     private function _save_filter(){
        $v_MA_NGACH_filter = $this->get_post_var('cbx_MA_NGACH_filter');
        return array(
            'cbx_MA_NGACH_filter' => $v_MA_NGACH_filter
        );
    }
    function dsp_all_bacngach(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $arr_filter = $this->_save_filter();
        $VIEW_DATA['arr_filter']           = $arr_filter;
        $VIEW_DATA['arr_all_bacngach']     = $this->model->qry_all_bacngach_filter($arr_filter);
        $VIEW_DATA['arr_all_ngach_filter'] = $this->model->SELECT_NGACH_tatca();
        $this->view->render('dsp_all_bacngach', $VIEW_DATA);
    }
    public function dsp_single_bacngach($MA_BAC_NGACH){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $MA_BAC_NGACH = replace_bad_char($MA_BAC_NGACH);
        $VIEW_DATA['arr_single_bacngach'] = $this->model->qry_single_bacngach($MA_BAC_NGACH);
        $VIEW_DATA['arr_all_ngach'] = $this->model->SELECT_NGACH_nothing();
        $this->view->render('dsp_single_bacngach', $VIEW_DATA);
    }
    public function update_bacngach(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_bacngach';
        $this->model->update_bacngach();
    }
    public function delete_bacngach(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_bacngach';
        $this->model->delete_bacngach();
    }
}